*** First-year exam scores by pool status and gender, MI subjects and non-MI subjects. Figures F1 and F2

clear

use "${data}cleaned_data_y3.dta", clear

do "${blocks}construct_new_variables"

drop if ApplyYear>=2017

tab Course_NatSci_split_str

gen GenderPool_ad = ""
replace GenderPool_ad = "Pooled female" if Gender == "Female" & WinterPool == 1
replace GenderPool_ad = "Direct male" if Gender == "Male" & WinterPool == 0
replace GenderPool_ad = "Direct female" if Gender == "Female" & WinterPool == 0
replace GenderPool_ad = "Pooled male" if Gender == "Male" & WinterPool == 1

encode GenderPool_ad, gen(GenderPool)

replace Course_NatSci_split_str="Biological Sciences" if Course_NatSci_split_str=="Biological NatSci"
replace Course_NatSci_split_str="Physical Sciences" if Course_NatSci_split_str=="Physical NatSci"

foreach x in "Economics" "Engineering" "Mathematics" "Physical Sciences"  {

distplot ns_std_perc_y1 if inrange(ns_std_perc_y1, -3, 3) & Course_NatSci_split_str=="`x'", over(GenderPool) xlabel(-3(1)3, format(%9.0f)) ytitle("") xtitle("Standardized percentage score") subtitle("`x'") graphregion(fc(white)) ///
lc(sienna navy*0.3 sienna*0.3 navy) lp(solid solid dash dash) legend(size(*0.85)) aspectratio(0.8) legend(span) saving("${temp}`x'.gph", replace) 
}

grc1leg2 "${temp}Economics.gph" "${temp}Engineering.gph" "${temp}Mathematics.gph" "${temp}Physical Sciences.gph", graphregion(margin(t=10 b=10 l=35 r=35) fc(white)) r(3) c(2) iscale(0.5)

graph export "${graphs}gender_split_MI.pdf", as(pdf) replace 


foreach x in "Biological Sciences" "Law" "Medicine"  {

distplot ns_std_perc_y1 if inrange(ns_std_perc_y1, -3, 3) & Course_NatSci_split_str=="`x'", over(GenderPool) xlabel(-3(1)3, format(%9.0f)) ytitle("") xtitle("Standardized percentage score") subtitle("`x'") graphregion(fc(white)) ///
lc(sienna navy*0.3 sienna*0.3 navy) lp(solid solid dash dash) legend(size(*0.85)) aspectratio(0.8) legend(span) saving("${temp}`x'.gph", replace) 

}

grc1leg2 "${temp}Biological Sciences.gph" "${temp}Law" "${temp}Medicine.gph", graphregion(margin(t=10 b=10 l=35 r=35) fc(white)) r(2) c(2) iscale(0.5)

graph export "${graphs}gender_split_nonMI.pdf", as(pdf) replace 

